﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Apparat.Renderables.AssimpMeshInterface
{
    public class AssimpAux
    {
        public static Assimp.Matrix4x4 ToAssimpMatrix4x4(SlimDX.Matrix mat)
        {
            mat = SlimDX.Matrix.Transpose(mat);

            Assimp.Matrix4x4 result;
            result.A1 = mat.M11;
            result.A2 = mat.M12;
            result.A3 = mat.M13;
            result.A4 = mat.M14;
            result.B1 = mat.M21;
            result.B2 = mat.M22;
            result.B3 = mat.M23;
            result.B4 = mat.M24;
            result.C1 = mat.M31;
            result.C2 = mat.M32;
            result.C3 = mat.M33;
            result.C4 = mat.M34;
            result.D1 = mat.M41;
            result.D2 = mat.M42;
            result.D3 = mat.M43;
            result.D4 = mat.M44;

            return result;
        }


        public static SlimDX.Matrix ToSlimDXMatrix(Assimp.Matrix4x4 mat)
        {
            SlimDX.Matrix result = new SlimDX.Matrix();
            result.M11 = mat.A1;
            result.M12 = mat.A2;
            result.M13 = mat.A3;
            result.M14 = mat.A4;

            result.M21 = mat.B1;
            result.M22 = mat.B2;
            result.M23 = mat.B3;
            result.M24 = mat.B4;

            result.M31 = mat.C1;
            result.M32 = mat.C2;
            result.M33 = mat.C3;
            result.M34 = mat.C4;

            result.M41 = mat.D1;
            result.M42 = mat.D2;
            result.M43 = mat.D3;
            result.M44 = mat.D4;

            return result;
        }

        public static SlimDX.Matrix ToSlimDXMatrixTransposed(Assimp.Matrix4x4 mat)
        {
            SlimDX.Matrix result = new SlimDX.Matrix();
            result.M11 = mat.A1;
            result.M12 = mat.A2;
            result.M13 = mat.A3;
            result.M14 = mat.A4;

            result.M21 = mat.B1;
            result.M22 = mat.B2;
            result.M23 = mat.B3;
            result.M24 = mat.B4;

            result.M31 = mat.C1;
            result.M32 = mat.C2;
            result.M33 = mat.C3;
            result.M34 = mat.C4;

            result.M41 = mat.D1;
            result.M42 = mat.D2;
            result.M43 = mat.D3;
            result.M44 = mat.D4;

            return SlimDX.Matrix.Transpose(result);
        }
    }
}
